package com.hwhy.systemmonitoring.common.util;

import java.util.Date;

/**
 * 日期处理工具
 * @author LIFULIN
 * @className DateUtil
 * @description TODO 日期处理工具
 * @date 2020/4/28-18:28
 */
public class DateUtil {

    /**
     * 计算两个时间差
     *
     * @param endDate 结束时间
     * @param nowDate 开始时间
     * @return 计算的结果
     */
    public static String getDatePoor(Date endDate, Date nowDate) {
        long nd = (long) 1000 * 24 * 60 * 60;
        long nh = (long) 1000 * 60 * 60;
        long nm = (long) 1000 * 60;
        // 获得两个时间的毫秒时间差异
        long diff = endDate.getTime() - nowDate.getTime();
        // 计算差多少天
        long day = diff / nd;
        // 计算差多少小时
        long hour = diff % nd / nh;
        // 计算差多少分钟
        long min = diff % nd % nh / nm;
        // 计算差多少秒//输出结果
        return day + "天" + hour + "小时" + min + "分钟";
    }
}
